var funObj={
	inits:function(){
		this.ajax();
	},
	Interface:{
		 bannerlist:"http://ww.yc630.com/api/index.php/Buyer/Buyer/bannerlist", //banner接口
		 goodsTyle:"http://ww.yc630.com/api/index.php/Buyer/Goods/goodsTyle",  //人群分类和商品风格 
		 homeGoodsbrand:"http://ww.yc630.com/api/index.php/Buyer/Goods/homeGoodsbrand"         // 品牌推荐页
	},
	ajax:function(){
		common.ajaxFun(funObj.Interface.bannerlist,"POST",{token:token},funObj.bannerFun); //banner图
		common.ajaxFun(funObj.Interface.homeGoodsbrand,"POST",{token:token},funObj.navFun); //nav数据
		common.ajaxFun(funObj.Interface.homeGoodsbrand,"POST",{token:token},funObj.clothingFun); //品牌展示
	},
	bannerFun:function(res){
		var str="";
		$.each(res.data,function(i,v){
			str+='<li><a href="'+v.link+'" name="'+v.name+'" id='+v.id+'><img src="'+v.img+'"></a></li>'
		});
		$("#picbox ul").html(str);
		banner();

	},
	navFun:function(res){
		var str="";
		$.each(res.data,function(i,v){
				str+='<li><dl><dd>'
				$.each(v.goods_style,function(k,l){
					str+='<span id='+k+' good_style='+v.peoplestyleid+'>'+l+'</span>'
				})
				str+='</dd><dt key='+v.peoplestyleid+'>'+v.people_style+'</dt></dl></li>'
		});
		$("#nav").html(str);
		$("#nav dl").on("mouseover",function(){
			$(this).addClass("cru");
		})
		$("#nav dl").on("mouseleave",function(){
			$("#nav dl").removeClass("cru");
		});
		funObj.goCommodityHomeFun($("#nav span"));
	},
	clothingFun:function(res){
		var str="";
		$.each(res.data,function(i,v){
			str+='<div class="group"><div class="groupTIt" key='+v.peoplestyleid+'>'+v.people_style+'</div><ul class="BrandOptions" >'
			$.each(v.goods_style,function(a,b){
				str+='<li id='+a+' good_style='+v.peoplestyleid+'>'+b+'</li>'
			});
			str+='</ul><div class="BrandGroup"><ul>'
			$.each(v.brand,function(a,b){
				str+='<li id='+a+'><div><img src='+b.img+' alt='+b.name+'></div>'+
		  				'<p><span>'+b.name+'</span></p>'+
		 			'</li>'
			});
			str+='</ul></div></div>'
		});
		$("#clothing").html(str);
		funObj.goCommodityHomeFun($(".group ul.BrandOptions li"));
		funObj.gobrandHomeFun();
	},
	goCommodityHomeFun:function(ele){
		ele.on("click",function(){
			var people_style=$(this).attr("good_style"),
				good_style=$(this).attr("id");
				window.location.href="./CommodityHome.html?people_style="+people_style+"&goods_style="+good_style;
		});
	},
	gobrandHomeFun:function(){
		$(".BrandGroup").on("click","li",function(){
			var brand=$(this).attr("id"),
			people_style=$(this).parents("div.BrandGroup").siblings("div.groupTIt").attr("key");
			window.location.href="./brandHome.html?people_style="+people_style+"&brand="+brand;
		});
	}
}
funObj.inits();